@model IEnumerable<SealManagement.Models.SignMakerInfo>

	@{
	ViewData["Titel"] = "制章人列表";
	}

	@*
	<!DOCTYPE html>

	<html>
		<head>
			<meta name="viewport" content="width=device-width" />
			<title>制章人列表</title>
			<link href="~/Content/layui/css/layui.css" rel="stylesheet" />
			
			<style type="text/css">
				.contain {
					font-family: ‘ Microsoft YaHei ’;
					margin: 15px auto;
					width: 1600px;
				}

				table {
					border: 1px solid #e3e6e8;
					border-collapse: collapse;
					display: table;
					table-layout: fixed;
					text-align: center;
					width: 100%;
				}

				th,
				td {
					border: 1px solid #e3e6e8;
					height: 38px;
					line-height: 38px;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				th {
					background-color: #EBEBEB;
					color: #000;
				}

				.layui-layer {
					word-break: break-all;
					word-wrap: break-word;
				}
			</style>
		</head>
		<body>*@
			<h2 style="margin:20px 0">制章人列表</h2>
			<hr />

			<div class="">
				<table class="table fixed table-hover">
					<thead>
						<tr>
							<th class="text-center" style="width:100px;">
								用户名
							</th>
							<th class="text-center " style="width:100px;">
								证书序列号
							</th>
							<th class="text-center ">
								证书使用者
							</th>
							<th class="text-center " style="width:120px;">
								证书颁发者
							</th>

							<th class="text-center">
								创建日期
							</th>
							<th class="text-center ">
								备注
							</th>
							<th class="text-center ">证书开始日期</th>
							<th class="text-center ">
								证书过期日期
							</th>
							<th class="text-center ">证书</th>
							<th class="text-center ">操作</th>
						</tr>
					</thead>

					<tbody id="userList"></tbody>
				</table>
				<div style="width:100%">
					<div id="Page" style="margin:10px auto;"></div>
				</div>
			</div>




			<script src="~/js/utils.js"></script>

			<script src="~/lib/jquery/jquery-1.12.4.min.js"></script>
			<script src="~/Content/layui/layui.js"></script>
			<script>
				$(function() {
					layui.use(['layer', 'table'],
						function() {
							var layer = layui.layer,
								table = layui.table;

							//$("td").on("mouseenter", function () {
							$('#userList').on('mouseenter', 'td', function() {
								//js主要利用offsetWidth和scrollWidth判断是否溢出。
								//在这里scrollWidth是包含内容的完全高度，offsetWidth是当前表格单元格的宽度。
								if (this.offsetWidth < this.scrollWidth) {
									var that = this;
									var text = $(this).text();
									layer.tips(text, that, {
										tips: [1, '#5BC0DE'],
										time: 2000,
										area: ['300px', 'auto'],
									});

								}
							});
						});
				});
				
				
				$(function() {
					$('#userList').on('click', '.Del', function() {
						//var Id = $('#hidden').val();
						var Id = $(this).attr('data');
						//var url = $(this).attr('href');
						//var params = {
						//    id: Id
						//};
						layer.open({
							type: 1,
							offset: 'auto',
							id: 'confirm',
							move: false,
							title: '确认窗口',
							scrollbar: true,
							content: '<div style="padding: 20px 40px;"> 确定删除吗？</div>',
							btn: ['确认', '取消'],
							scrollbar: false,
							resize: false,
							moveType: 1 //拖拽模式，0或者1
								,
							area: ['200px', '160px'],
							btnAlign: 'c' //按钮居中
								,
							shade: 0 //不显示遮罩
								,
							yes: function() {
							var base64 = new Base64();
								EncryptCertList((data) => {
									data = JSON.parse(data);
let CertID = getCookie("CertID");
									//加密的字符串
									var str = JSON.stringify({
										Id:Id,
										
										validatecode:"@ViewBag.ValidateCode"
									});
								
									var External = {
										CertID: CertID,
										//编码
										DataBase64: base64.encode(str)
									};
								
									ExternalEncrypt(JSON.stringify(External), (data) => {
										data = JSON.parse(data);
                                        if (data.error == "Ok") {
                                            $.ajax({
                                                url: "/SignMaker/Delete/",
                                                type: 'Get',
                                                data: {
                                                    EncryptData: data.contentBase64
                                                },
                                                success: function (data) {
                                                    if (data != null && data.state == '200') {
                                                        layer.msg(data.message, {
                                                            time: 500
                                                        }, function () {
                                                            window.location.reload();
                                                        });

                                                    } else {
                                                        layer.msg(data.message);
                                                    }
                                                }
                                            });
                                            layer.closeAll();
                                        }  else {
                                layer.msg(data.error)
                            }
									});
								})
								
							},
							btn2: function(index, layero) {
								//按钮【按钮二】的回调
								layer.close();
								//return false 开启该代码可禁止点击该按钮关闭
							}
						});
					});
				})
			</script>
			<script>
				function down(id) {
					let base64 = new Base64();
					EncryptCertList((data) => {
						data = JSON.parse(data);
let CertID = getCookie("CertID");
						//加密的字符串
						var str = JSON.stringify({
							Id: id,
							
						});
						var External = {
							CertID: CertID,
							//编码
							DataBase64: base64.encode(str)
						};
				
						ExternalEncrypt(JSON.stringify(External), (data) => {
							data = JSON.parse(data);
							if (data.error == "Ok") {
								var d = data.contentBase64;
								var reg = new RegExp('\\+', "g")
								var dd = d.replace(reg, '%2B');
								location.href = "/SignMaker/DownCert?EncryptData=" + dd;
								
							} else {
                                layer.msg(data.error)
                            }
						});
					})
				}
				function doSomeThing(id, url, type, href) {
					let base64 = new Base64();
					EncryptCertList((data) => {
						data = JSON.parse(data);
let CertID = getCookie("CertID");
						//加密的字符串
						var str = JSON.stringify({
							Id: id,
							
						});
						var External = {
							CertID: CertID,
							//编码
							DataBase64: base64.encode(str)
						};
				
						ExternalEncrypt(JSON.stringify(External), (data) => {
							data = JSON.parse(data);
							if (data.error == "Ok") {
								var dataToPost = {
									EncryptData: data.contentBase64
								};
								console.log(JSON.stringify(dataToPost));
								$.ajax({
									url: "/SignMaker/" + url,
									type: type,
									// contentType: 'application/json',
									// dataType: 'JSON',
									data: dataToPost,
									success: function(data) {
										if (data != null && data.state == '200') {
											window.location.href = href;
										} else {
											layer.msg(data.message);
											return;
										}
									},
									error: (e) => {
										console.log(e, "11")
									}
								});
							} else {
                                layer.msg(data.error)
                            }
						});
					})
				}
				function edit(id){
					let base64 = new Base64();
					console.log(id)
					EncryptCertList((data) => {
						data = JSON.parse(data);
let CertID = getCookie("CertID");
						//加密的字符串
						var str = JSON.stringify({
							Id: id,
							
						});
					
						var External = {
							CertID: CertID,
							//编码
							DataBase64: base64.encode(str)
						};
					
						ExternalEncrypt(JSON.stringify(External), (data) => {
							data = JSON.parse(data);
							if (data.error == "Ok") {
								var dataToPost = {
									// ArrayNo: CertID,
									EncryptData: data.contentBase64
								};
								console.log( JSON.stringify(dataToPost));
								 $.ajax({
								    url: "/SignMaker/Edit",
								    type: 'GET',
								    // contentType: 'application/json',
								    // dataType: 'JSON',
								    data: dataToPost,
								    success: function (data) {
								        if (data != null && data.state == '200') {
								           // window.location.href="/SignMaker/Edit"
								            
								        } else {
								            layer.msg(data.message);
								            return;
								        }
								    },
									error:(e)=>{
										console.log(e,"11")
									}
								});
							} else {
                                layer.msg(data.error)
                            }
						});
					})
				}
				$(function() {
					$(document).ready(function() {
						//ajax请求后台数据
						getUserList(10, 1);

					});
					var currentPage = 1;
					//数据请求
					function getUserList(PageSize, PageIndex) {
						$.ajax({
							url: "/SignMaker/Index",
							type: 'POST',
							data: {
								PageSize,
								PageIndex
							},
							success: function(result) {
								console.log(result);
								var Items = result.data;
								var total = result.total;
								//console.log(total);
								showData(Items);
								pages(total);
							}
						});
					}
					// 展示数据
					function showData(Items) {
						var _html = '';
						$.each(Items, function(i) {
							var Item = Items[i];
							_html += ' <tr class="text-center ">';
							_html += '<td style="width:100px;overflow:hidden;word-break: break-all;vertical-align: middle;">' + Item.signMaker
								.userName + '</td >';
							_html +=
								'<td style="width:130px;word-wrap:break-word;text-overflow: ellipsis;word-break: break-all;vertical-align: middle;">' +
								Item.signMaker.arrayNo + '</td >';
							_html += '<td style="vertical-align: middle;word-wrap:break-word;" >' + Item.subject + '</td >';
							_html += '<td  style="width:150px;word-wrap:break-word;vertical-align: middle;">' + Item.issuer + '</td >';
							_html += '<td  style="vertical-align: middle;"  >' + Item.signMaker.createDate + '</td >';
							_html += '<td  style="vertical-align: middle;" >' + Item.signMaker.remark + '</td >';
							_html += '<td style="vertical-align: middle;" >' + Item.notBefore + '</td >';
							_html += '<td  style="vertical-align: middle;" >' + Item.notAfter + '</td >';
							_html += '<td style="width:80px;vertical-align: middle;">';
                            _html += '<a onclick="down(' + Item.signMaker.id + ')" style=" text-decoration:underline;color:blue;cursor: pointer;">点击下载</a>';
							_html += '</td > ';
							_html += '<td  style="vertical-align: middle;" >';
							_html += '<a onclick="doSomeThing(' + Item.signMaker.id + 
								',\'Detail\',\'POST\',\'/SignMaker/DetailForViewShow\')" style="cursor: pointer;">查看</a> |';
							// _html += '<a onclick="edit('+Item.user.id+')">编辑</a> |';
                            _html += '<a onclick="doSomeThing(' + Item.signMaker.id + ',\'Edit\',\'GET\',\'/SignMaker/EditForViewShow\')" style="cursor: pointer;">编辑</a> |';
                            _html += '<a class="Del" href ="javascript:void(0)" data="' + Item.signMaker.id + '" style="cursor: pointer;">删除</a>';
							_html += '</td ></tr> ';
						})
						$("#userList").html(_html);

					}
					// 分页条
					function pages(allNum) {
						layui.use(['laypage', 'layer'], function() {
							var laypage = layui.laypage,
								layer = layui.layer;
							laypage.render({
								elem: 'Page',
								count: allNum //数据总数，从服务端得到
									,
								curr: currentPage,
								theme: '#393D49',
								jump: function(obj, first) {
									currentPage = obj.curr;
									//首次不执行
									if (!first) {
										getUserList(10, obj.curr)
									}
								}
							});
						})
					};
				})
			</script>
			@*
		</body>
	</html>*@
